***************
**PLEASE NOTE**
***************

*The first part of this dofile reproduces the figures and numerical results in the manuscript (in the order presented) and the second part reproduces the figures and numerical results in the online appendix (also in the order presented). All figures are saved in the "Figures" folder.

*Remember to install the required packages and change the directory before running this dofile.

ssc install krippalpha
ssc install _gwtmean
ssc install addplot

cd "U:\Papers\Degrees of Disrespect\All_data_and_dofiles\Replication files for JOP"
mkdir "Figures"
mkdir "Temp_figures"
*log using log_Stata, text

********************************************************
**CODE FOR SECTION CALLED "DESIGN OF CONTENT ANALYSIS"**
********************************************************

*Loading data for first round coding
quietly {
clear all
use "data_Content_analysis_data_from_first_round.dta"
}

*Counting number of coders in first coding round (see paragraph starting with "The tweets were...")
quietly {
	by Respondentid, sort: gen n_coders = _n == 1
	}
count if n_coders == 1

*Counting number of ratings in first coding roundt (see paragraph starting with "The tweets were...")
count

*Generating variable (Share_criticism) measuring percentage saying tweet contained criticism or expressions of disagreement in first coding round
quietly {
clonevar Dummy_contains = Contains
replace Dummy_contains = 0 if Dummy_con == 9
egen Share_criticism = mean(Dummy_con), by(TweetID)
}

*Counting the number of tweets that a majority of coders say contain criticism or expressions of disagreement in first coding round (see paragraph starting with "In the second round...")
quietly {
gen Contain_dummy = 1 if Share_criticism > 0.5 & Share_criticism != .
replace Contain_dummy = 0 if Share_criticism <= 0.5 & Share_criticism != .
duplicates drop TweetID, force
drop Coder*
drop Resp*
drop if Contain_dummy != 1
}
count

*Examining reliability of first round coding (see footnote starting with "Every eighth tweet was...")
quietly {
clear all
use "data_Content_analysis_data_from_first_round.dta"
clonevar Dummy_contains = Contains
replace Dummy_contains = 0 if Dummy_con == 9
egen Initial = mean(Dummy_con) if Extra == 0, by(TweetID)
egen Extra = mean(Dummy_con) if Extra == 1, by(TweetID)
egen Share_initial = max(Initial), by(TweetID)
egen Share_extra = max(Extra), by(TweetID)
gen Contain_dummy_initial = 1 if Share_initial > 0.5 & Share_initial != .
replace Contain_dummy_initial = 0 if Share_initial <= 0.5 & Share_initial != .
gen Contain_dummy_extra = 1 if Share_extra > 0.5 & Share_extra != .
replace Contain_dummy_extra = 0 if Share_extra <= 0.5 & Share_extra != .
duplicates drop TweetID, force
drop Coder*
drop Resp*
drop if Contain_dummy_extra == .
}
krippalpha Contain_dummy_initial Contain_dummy_extra

quietly {
gen agreement = 0 if Contain_dummy_initial != Contain_dummy_extra
replace agreement = 1 if Contain_dummy_initial == Contain_dummy_extra
}
tab agreement

*Counting number of real-life tweets coded in second round (see paragraph starting with "In the second round...")
quietly {
clear all
use "data_Content_analysis_data_from_second_round.dta"
duplicates drop TweetID, force
drop if TweetID == . | TweetID < 0
}
count

*Counting the number of coders in second coding round (see bottom of paragraph starting with "In the second round...")
quietly {
clear all
use "data_Content_analysis_data_from_second_round.dta"
by RespondentID, sort: gen n_coders = _n == 1
}
count if n_coders == 1

*Counting the number of ratings in second coding round (see bottom of paragraph starting with "In the second round...")
count

*Examining reliability of second round coding (see footnote starting with "196 tweets were...")
quietly {
clear all
use "data_Content_analysis_data_from_second_round.dta"

***Creating relevant variables***

*Creating variable measuring share of coders that indicate that the tweet does not to contain criticism or disagreement
egen ratings_per_tweet = count(Rating), by(TweetID)
egen number_of_no_dis1 = count(Rating) if Rating == 6, by(TweetID)
egen number_of_no_dis2 = max(number_of_no_dis1), by(TweetID)
gen share_no_dis_or_crit = number_of_no_dis2/ratings_per_tweet
replace share_no_dis_or_crit = 0 if share_no_dis_or_crit == .

*Creating new scale for ratings of inciviltiy
gen NewRating = (Rating-1)/4 if Rating != 6 & Rating != 7

*Creating variable with only three categories for party identification (PID)
gen Three_cat_PID =.
replace Three_cat_PID = 1 if PartyID == 1 | PartyID == 2 | PartyID == 3
replace Three_cat_PID = 2 if PartyID == 4
replace Three_cat_PID = 3 if PartyID == 5 | PartyID == 6 | PartyID == 7

*Dropping_if_tweet_is_not_rated
drop if NewRating == .

*Creating alternative aggregation measures for use in later analysis
	*Simple average*
	egen Simple_average = mean(NewRating), by(TweetID)

	*Partial pooling - random intercepts by tweet*
	mixed NewRating || TweetID:
	predict b
	predict b1, reffects relevel(TweetID)
	gen Average_rating_partial_pooling = b+b1

*Dropping all who are not partisans/independents
drop if PartyID == .

*Creating weights
	*Note: Democrats (incl. leaners) are set to 45 percent, Independents to 11 percent, and Republicans (incl. leaners) to 44 percent.

	*All ratings*
	egen count_per_subgroup_tot = count(NewRating), by(TweetID Three_cat_PID)
	gen weight_tot = 0.45/count_per_subgroup_tot if Three_cat_PID == 1
	replace weight_tot = 0.11/count_per_subgroup_tot if Three_cat_PID == 2
	replace weight_tot = 0.44/count_per_subgroup_tot if Three_cat_PID == 3

	*Only initial ratings*
	egen count_per_subgroup_ini = count(NewRating) if Extra == 0, by(TweetID Three_cat_PID)
	gen weight_ini = 0.45/count_per_subgroup_ini if Three_cat_PID == 1
	replace weight_ini = 0.11/count_per_subgroup_ini if Three_cat_PID == 2
	replace weight_ini = 0.44/count_per_subgroup_ini if Three_cat_PID == 3

	*Only extra ratings*
	egen count_per_subgroup_ext = count(NewRating) if Extra == 1, by(TweetID Three_cat_PID)
	gen weight_ext = 0.45/count_per_subgroup_ext if Three_cat_PID == 1
	replace weight_ext = 0.11/count_per_subgroup_ext if Three_cat_PID == 2
	replace weight_ext = 0.44/count_per_subgroup_ext if Three_cat_PID == 3

*Creating weighted means of ratings
	*All ratings*
	egen Weighted_tot_average = wtmean(NewRating), by(TweetID) weight(weight_tot)

	*Only initial ratings*
	egen Ini = wtmean(NewRating) if Extra == 0, by(TweetID) weight(weight_ini)
	egen Weighted_ini_average = max(Ini), by(TweetID)

	*Only extra ratings*
	egen Ext = wtmean(NewRating) if Extra == 1, by(TweetID) weight(weight_ext)
	egen Weighted_ext_average = max(Ext), by(TweetID)

*Dropping duplicates
duplicates drop TweetID, force
sort Content
}
krippalpha Weighted_ext_average Weighted_ini_average if (Weighted_ini_average != . & Weighted_ext_average != .), method(interval)

*Creating Figure 2 and saving it in folder called "Figures"*
quietly {

*Looking at average ratings of mock tweets
tab Weighted_tot_average if Mock_t == 1

*Making the plot - note that tweets that at least 25 percent of coders state contain no criticism or disagreement are excluded (see footnote in manuscript)
kdensity Weighted_tot_average if Trump == 0 & Mock_t == 0 & share_no_dis_or_crit < 0.25, bwidth(0.04) scheme(s1mono) xlabels(0.36 0.54 0.65 0.75 0.87 0.92) lcolor(black)

*Editing the plot

*Making space for mock tweets
gr_edit title.draw_view.setstyle, style(no)
gr_edit note.style.editstyle margin(vlarge) editcopy
gr_edit note.style.editstyle drawbox(yes) editcopy
gr_edit note.style.editstyle boxmargin(large) editcopy
gr_edit xaxis1.title.draw_view.setstyle, style(no)
gr_edit note.style.editstyle fillcolor(none) editcopy
gr_edit note.style.editstyle linestyle(color(none)) editcopy
gr_edit note.style.editstyle color(white) editcopy

*Adding 0.36-tweet
gr_edit AddTextBox added_text editor 32 3
gr_edit added_text[1].text.Arrpush `"While I respect them and believe in their good intentions,"'
gr_edit added_text[1].text.Arrpush `"Senate Democrats [Republicans] have placed America's"'
gr_edit added_text[1].text.Arrpush `"vulnerable children and their health care at risk. It's time"'
gr_edit added_text[1].text.Arrpush `"to end their government shutdown and fund CHIP."'
gr_edit added_text[1].text.Arrpush  #DemShutdown [GOPShutdown]
gr_edit added_text[1].style.editstyle size(2.8)

*Adding 0.75-tweet
gr_edit AddTextBox added_text editor 17 23
gr_edit added_text[2].text.Arrpush `"Cruel and heartless Senate Democrats have placed Ame-"'
gr_edit added_text[2].text.Arrpush `"rica's vulnerable children and their health care at risk."'
gr_edit added_text[2].text.Arrpush `"It's time to end their government shutdown and fund CHIP."'
gr_edit added_text[2].text.Arrpush `" #DemShutdown [GOPShutdown]"'
gr_edit added_text[2].style.editstyle size(2.8)

*Adding 0.92-tweet
gr_edit AddTextBox added_text editor 3.5 43
gr_edit added_text[3].text.Arrpush `"EVIL AND BOTTOM-FEEDING Senate Democrats have"'
gr_edit added_text[3].text.Arrpush `"placed America's vulnerable children and their health care"'
gr_edit added_text[3].text.Arrpush `"at risk!! It's time to end their CRUEL government shutdown"'
gr_edit added_text[3].text.Arrpush `"and fund CHIP. #DemShutdown [GOPShutdown]"'
gr_edit added_text[3].style.editstyle size(2.8)

*Adding boxes
gr_edit added_text[1].style.editstyle drawbox(yes) editcopy
gr_edit added_text[1].style.editstyle fillcolor(none) editcopy
gr_edit added_text[1].style.editstyle linestyle(pattern(tight_dot)) editcopy
gr_edit added_text[1].style.editstyle margin(vsmall) editcopy
gr_edit added_text[2].style.editstyle drawbox(yes) editcopy
gr_edit added_text[2].style.editstyle fillcolor(none) editcopy
gr_edit added_text[2].style.editstyle linestyle(pattern(tight_dot)) editcopy
gr_edit added_text[2].style.editstyle margin(vsmall) editcopy
gr_edit added_text[3].style.editstyle drawbox(yes) editcopy
gr_edit added_text[3].style.editstyle fillcolor(none) editcopy
gr_edit added_text[3].style.editstyle linestyle(pattern(tight_dot)) editcopy
gr_edit added_text[3].style.editstyle margin(vsmall) editcopy

*Lines
gr_edit AddLine added_lines editor 50.32763006191273 48.31459630537118 46 39.72654166912183
gr_edit AddLine added_lines editor 99.4291926107424 48.31459630537118 88.67845309574327 23.21839220166471
gr_edit AddLine added_lines editor 120.8855976892408 48.31459630537118 105.9499851975336 9.668350442249036
gr_edit added_lines[1].style.editstyle linestyle(pattern(tight_dot)) editcopy
gr_edit added_lines[2].style.editstyle linestyle(pattern(tight_dot)) editcopy
gr_edit added_lines[3].style.editstyle linestyle(pattern(tight_dot)) editcopy
graph save "Figures\Figure2.gph", replace
}

*Creating temporary figures that will later be used when creating Figure 4
quietly {

*Creating distribution of incivility in all tweets
kdensity Weighted_tot_average if Trump == 0 & Mock_t == 0 & share_no_dis_or_crit < 0.25, bwidth(0.04) scheme(s1mono) xlabels(0.36 0.54 0.65 0.75 0.87 0.92) lcolor(black)
gr_edit title.draw_view.setstyle, style(no)
gr_edit xaxis1.title.draw_view.setstyle, style(no)
gr_edit note.draw_view.setstyle, style(no)
gr_edit yaxis1.title.draw_view.setstyle, style(no)
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
graph save "Temp_figures\top_of_figure4A.gph", replace

*Creating distribution of incivility in tweets by men
kdensity Weighted_tot_average if Trump == 0 & Mock_t == 0 & share_no_dis_or_crit < 0.25 & Gender_of == "M", bwidth(0.04) scheme(s1mono) xlabels(0.36 0.54 0.65 0.75 0.87 0.92) lcolor(black) ylabels(0 1 2 3)
gr_edit title.draw_view.setstyle, style(no)
gr_edit xaxis1.title.draw_view.setstyle, style(no)
gr_edit note.draw_view.setstyle, style(no)
gr_edit yaxis1.title.draw_view.setstyle, style(no)
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
graph save "Temp_figures\top_of_figure4B.gph", replace

*Creating distribution of incivility in tweets by women
kdensity Weighted_tot_average if Trump == 0 & Mock_t == 0 & share_no_dis_or_crit < 0.25 & Gender_of == "F", bwidth(0.04) scheme(s1mono) xlabels(0.36 0.54 0.65 0.75 0.87 0.92) lcolor(black) ylabels(0 1 2 3)
gr_edit title.draw_view.setstyle, style(no)
gr_edit xaxis1.title.draw_view.setstyle, style(no)
gr_edit note.draw_view.setstyle, style(no)
gr_edit yaxis1.title.draw_view.setstyle, style(no)
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
graph save "Temp_figures\top_of_figure4C.gph", replace
}

*Saving a working dataset that will be used in later analysis
quietly {
save "workingdatatweets.dta", replace
}

*********************************************************
**CODE FOR SECTION CALLED "DESIGN OF SURVEY EXPERIMENT"**
*********************************************************

*Counting number of respondents in each sample (see paragraph starting with "In the experiment...")
quietly {
clear all
use "data_Experimental_data.dta"
}
tab Sample

*Calculating descriptive statistics for my dependent variable (see paragraph starting with "After reading the...")
sum Rating_Miller
tab Rating_Miller

******************************************
**CODE FOR SECTION CALLED "MAIN RESULTS"**
******************************************

*Creating all variables and saving a working dataset for use in later analyses*
quietly {
clear all
use "data_Experimental_data.dta"
	
*Creating dummy variable for party identification
gen Dem0Rep1 = .
replace Dem0Rep1 = 1 if Ind == 1
replace Dem0Rep1 = 0 if Ind == 3
replace Dem0Rep1 = 1 if PartyID == 1
replace Dem0Rep1 = 0 if PartyID == 2

*Creating 7-point variable for party identification
gen sevenpoint_partyid = .
replace sevenpoint_partyid = 1 if StrongRep == 1
replace sevenpoint_partyid = 2 if StrongRep == 2
replace sevenpoint_partyid = 3 if Ind == 1
replace sevenpoint_partyid = 4 if Ind == 2
replace sevenpoint_partyid = 5 if Ind == 3
replace sevenpoint_partyid = 6 if StrongDem == 2
replace sevenpoint_partyid = 7 if StrongDem == 1

*Creating variable ranging from 0 to 1 for self-monitoring
gen SM = (((Self_monitoring_1-1)/6)*(-1)+1 + ((Self_monitoring_2-1)/6) + ((Self_monitoring_3-1)/6)*(-1)+1)/3

*Creating variable for in- or out-group status in experiment
gen Treat = .
replace Treat = 1 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_0jN6hKx1DnsHhM9"
replace Treat = 2 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_b3nTeeNcgXlvC0B"
replace Treat = 3 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_6SeL3183xDSSS5n"
replace Treat = 4 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_3qSIGYtWa5jabnT"
replace Treat = 5 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_6DmxbvpndG7LcoZ"
replace Treat = 6 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_7U9g25lPoUnyeYl"
replace Treat = 7 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_a9NPHTL9sGjKEcJ"
replace Treat = 8 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_03CqOvGtSMeAA9T"
replace Treat = 9 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_aY4MTYhl6k9CUNn"
replace Treat = 1 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_551WD6YPtXUwzT7"
replace Treat = 3 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_1Yo5nAgANSppsNL"
replace Treat = 4 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_6hvitJenCgKMehf"
replace Treat = 6 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_9RfkluLruMiCz5j"
replace Treat = 8 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_7PrXGOUHMcxEFGB"
replace Treat = 9 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_ekt7BJHBx7I61GB"
replace Treat = 11 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_9KPc1orQ7YalBVr"
replace Treat = 12 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_8iFlmILVqUr0K5n"
replace Treat = 13 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_4IrubdcJYu3vhD7"
replace Treat = 14 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_6ooLJbuAUXbJfeJ"
replace Treat = 15 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_9vOP61lDyRXWvB3"
replace Treat = 16 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_5cJZEZIxiy4Pmgl"
replace Treat = 17 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_3fxWTOWGJjxENlH"
replace Treat = 18 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_6GbAR2CvCoTMZQV"
replace Treat = 19 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_doqPsgkNABjsZLL"
replace Treat = 11 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_4UFWlhfQbRmBoRT"
replace Treat = 13 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_8fcTba9mapYjrAp"
replace Treat = 14 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_eINQefSaNG7XGex"
replace Treat = 16 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_8AJB4y1udZZqmbz"
replace Treat = 18 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_9ZI2K2d0z56Ajpb"
replace Treat = 19 if Rand == "https://aarhus.eu.qualtrics.com/ControlPanel/Graphic.php?IM=IM_7a2eelNNwz008TP"
gen out = .
replace out = 1 if Dem0 == 1 & Treat > 10
replace out = 0 if Dem0 == 0 & Treat > 10
replace out = 0 if Dem0 == 1 & Treat < 10
replace out = 1 if Dem0 == 0 & Treat < 10
label define in_out_party_status 0 "Miller is co-partisan" 1 "Miller is out-partisan"
label value out in_out_party_status

*Creating variable ranging from 0 to 1 for perceived incivility
gen perceived_rudeness = (Rude_polite-1)/4*(-1)+1 if Rude_polite != 6 & (Sample == 0 | Sample == 2)
replace perceived_rudeness = (Mancheck_1-1)/6*(-1)+1 if (Sample == 1)

*Creating variable ranging from 0 to 1 for perceived ideology
gen perceived_ideology = (Lib_con-1)/4*(-1)+1 if Lib_con != 6 & (Sample == 0 | Sample == 2)
replace perceived_ideology = (Mancheck_2-1)/6*(-1)+1 if (Sample == 1)

*Creating alternative favorability measure in SSI sample ranging from 0 to 100
gen AltFavorability = ((Favorability_1*(-1)+8 + Favorability_2)-2)/2/6*100

*Creating attention check variable (dummy)
gen Atcheck_passed = 0
replace Atcheck_passed = 1 if (Attention_check_7  != . & Attention_check_9 != .)
replace Atcheck_passed = 0 if Attention_check_1  != .
replace Atcheck_passed = 0 if Attention_check_2  != .
replace Atcheck_passed = 0 if Attention_check_3  != .
replace Atcheck_passed = 0 if Attention_check_4  != .
replace Atcheck_passed = 0 if Attention_check_5  != .
replace Atcheck_passed = 0 if Attention_check_6  != .
replace Atcheck_passed = 0 if Attention_check_8  != .
replace Atcheck_passed = 0 if Attention_check_10  != .
replace Atcheck_passed = 0 if Attention_check_11  != .
replace Atcheck_passed = 0 if Attention_check_12  != .
replace Atcheck_passed = 0 if Attention_check_13  != .
replace Atcheck_passed = 0 if Attention_check_14  != .
replace Atcheck_passed = 0 if Attention_check_15  != .
replace Atcheck_passed = 0 if Attention_check_16  != .
replace Atcheck_passed = 0 if Attention_check_17  != .
replace Atcheck_passed = 0 if Attention_check_18  != .

*Creating dummies to be used when conducting poooled analysis or restricting the analysis to specific experiments or samples
gen Pooled_analysis = 0
replace Pooled_analysis = 1 if (Sample == 0 | Sample == 1 | Sample == 2) & (Rudeness_0_to_100 != 41 & Rudeness_0_to_100 != 71 & Rudeness_0_to_100 != 82)
gen Only_male_version_of_exp = 0
replace Only_male_version_of_exp = 1 if  (Sample == 0 | Sample == 1) & (Rudeness_0_to_100 != 41 & Rudeness_0_to_100 != 71 & Rudeness_0_to_100 != 82),
gen Only_female_version_of_exp = 0
replace Only_female_version_of_exp = 1 if Sample == 2
gen Only_male_version_MTturk_sample = 0
replace Only_male_version_MTturk_sample = 1 if Sample == 0
gen Only_male_version_SSI_sample = 0
replace Only_male_version_SSI_sample = 1 if Sample == 1

save "workingdata.dta", replace
}

*Creating Figure 4 and saving it in folder called "Figures"*
quietly {

***Creating first column of Figure 4

*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(6) norescaling yscale(range(20 85)) fysize(65) xlabel(,angle(90) format(%04.2f)) saving("Temp_figures\temp.gph", replace)

*Making plot of averages in each conditions for out-partisans
drop if Pooled_analysis == 0
drop if out != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) msize(small) mcolor(black) mfcolor(black) lcolor(black) connect(1)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out-party_pooled.gph", replace

*Adding plot of averages in each conditions for co-partisans
clear all
use "workingdata.dta"
drop if Pooled_analysis == 0
drop if out != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out-party_pooled.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) msize(small) mcolor(black) mfcolor(black) lcolor(black) connect(1)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -1.5
gr_edit xaxis1.title.DragBy -1.5 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(pattern(dash)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(pattern(dash)) editcopy

*Saving figure
graph save "Temp_figures\In_and_out_pooled.gph", replace

*Combining
gr combine "Temp_figures\top_of_figure4A.gph" "Temp_figures\In_and_out_pooled.gph", col(1) ysize(2.2) graphregion(color(white)) xsize(1) imargin(0 0 0 0)  title("Pooled results")

*Making density plot white
gr_edit plotregion1.graph1.style.editstyle boxstyle(shadestyle(color(none))) editcopy
gr_edit plotregion1.graph1.style.editstyle boxstyle(linestyle(color(none))) editcopy

*Creating label for density plot
gr_edit plotregion1.graph1.yaxis1.title.draw_view.setstyle, style(yes)
gr_edit plotregion1.graph1.yaxis1.title.text = {}
gr_edit plotregion1.graph1.yaxis1.title.text.Arrpush Rudeness density

*Moving label backwards
gr_edit plotregion1.graph1.yaxis1.title.DragBy 0 -1.5

*Editing size of value labels
gr_edit plotregion1.graph1.yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(vlarge)))) editcopy
gr_edit plotregion1.graph2.yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(vlarge)))) editcopy
gr_edit plotregion1.graph2.xaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(vlarge)))) editcopy

*Slightly enlarging margin of entire plot
gr_edit style.editstyle margin(medlarge) editcopy

*Enlarging axis labels
gr_edit plotregion1.graph1.yaxis1.title.style.editstyle size(medsmall) editcopy
gr_edit plotregion1.graph2.yaxis1.title.style.editstyle size(medsmall) editcopy
gr_edit plotregion1.graph2.xaxis1.title.style.editstyle size(medsmall) editcopy

*Creating boxes around each plot
gr_edit plotregion1.graph1.plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy
gr_edit plotregion1.graph2.plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Hiding value labels below density plot
gr_edit plotregion1.graph1.xaxis1.style.editstyle majorstyle(tickstyle(position(inside))) editcopy
gr_edit plotregion1.graph1.xaxis1.style.editstyle majorstyle(tickstyle(show_labels(no))) editcopy

*Adding 0 and 1 ticks to top density plot to assure that x-axis is aligned with x-axis in plot below
gr_edit plotregion1.graph1.xaxis1.add_ticks 0 `""', tickset(major)
gr_edit plotregion1.graph1.xaxis1.add_ticks 1 `""', tickset(major)

*Saving
graph save "Temp_figures\Figure4a.gph", replace


***Creating second column of Figure 4

*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & Only_male_version_of_exp == 1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & Only_male_version_of_exp == 1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(6) norescaling yscale(range(20 85)) fysize(65) xlabel(,angle(90) format(%04.2f)) saving("Temp_figures\temp.gph", replace)

*Making plot of averages in each conditions for out-partisans
drop if Only_male_version_of_exp == 0
drop if out != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) msize(small) mcolor(black) mfcolor(black) lcolor(black) connect(1)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out-party_harry.gph", replace

*Adding plot of averages in each conditions for co-partisans
clear all
use "workingdata.dta"
drop if Only_male_version_of_exp == 0
drop if out != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out-party_harry.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) msize(small) mcolor(black) mfcolor(black) lcolor(black) connect(1)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -1.5
gr_edit xaxis1.title.DragBy -1.5 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(pattern(dash)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(pattern(dash)) editcopy

*Saving figure
graph save "Temp_figures\In_and_out_Harry.gph", replace

*Combining
gr combine "Temp_figures\top_of_figure4B.gph" "Temp_figures\In_and_out_Harry.gph", col(1) ysize(2.2) graphregion(color(white)) xsize(1) imargin(0 0 0 0) fxsize(29.8) title("Harry Miller version")

*Making density plot white
gr_edit plotregion1.graph1.style.editstyle boxstyle(shadestyle(color(none))) editcopy
gr_edit plotregion1.graph1.style.editstyle boxstyle(linestyle(color(none))) editcopy

*Creating label for density plot
gr_edit plotregion1.graph1.yaxis1.title.draw_view.setstyle, style(yes)
gr_edit plotregion1.graph1.yaxis1.title.text = {}
gr_edit plotregion1.graph1.yaxis1.title.text.Arrpush Rudeness density

*Moving label backwards
gr_edit plotregion1.graph1.yaxis1.title.DragBy 0 -1.5

*Editing size of value labels
gr_edit plotregion1.graph1.yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(vlarge)))) editcopy
gr_edit plotregion1.graph2.yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(vlarge)))) editcopy
gr_edit plotregion1.graph2.xaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(vlarge)))) editcopy

*Slightly enlarging margin of entire plot
gr_edit style.editstyle margin(medlarge) editcopy

*Enlarging axis labels
gr_edit plotregion1.graph1.yaxis1.title.style.editstyle size(medsmall) editcopy
gr_edit plotregion1.graph2.yaxis1.title.style.editstyle size(medsmall) editcopy
gr_edit plotregion1.graph2.xaxis1.title.style.editstyle size(medsmall) editcopy

*Creating boxes around each plot
gr_edit plotregion1.graph1.plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy
gr_edit plotregion1.graph2.plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Hiding value labels below density plot
gr_edit plotregion1.graph1.xaxis1.style.editstyle majorstyle(tickstyle(position(inside))) editcopy
gr_edit plotregion1.graph1.xaxis1.style.editstyle majorstyle(tickstyle(show_labels(no))) editcopy

*Adding 0 and 1 ticks to top density plot to assure that x-axis is aligned with x-axis in plot below
gr_edit plotregion1.graph1.xaxis1.add_ticks 0 `""', tickset(major)
gr_edit plotregion1.graph1.xaxis1.add_ticks 1 `""', tickset(major)

*Saving
graph save "Temp_figures\Figure4b.gph", replace


***Creating third column of Figure 4

*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & Only_female_version_of_exp == 1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & Only_female_version_of_exp == 1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(6) norescaling yscale(range(20 85)) xlabel(,angle(90) format(%04.2f)) fysize(65) saving("Temp_figures\temp.gph", replace)

*Making plot of averages in each conditions for out-partisans
drop if Only_female_version_of_exp == 0
drop if out != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) msize(small) mcolor(black) mfcolor(black) lcolor(black) connect(1)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out-party_harriet.gph", replace

*Adding plot of averages in each conditions for out-partisans
clear all
use "workingdata.dta"
drop if Only_female_version_of_exp == 0
drop if out != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out-party_harriet.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) msize(small) mcolor(black) mfcolor(black) lcolor(black) connect(1)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -1.5
gr_edit xaxis1.title.DragBy -1.5 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(pattern(dash)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(pattern(dash)) editcopy

*Saving figure
graph save "Temp_figures\In_and_out_Harriet.gph", replace

*Combining*
gr combine "Temp_figures\top_of_figure4C.gph" "Temp_figures\In_and_out_Harriet.gph", col(1) ysize(2.2) graphregion(color(white)) xsize(1) imargin(0 0 0 0) fxsize(29.8) title("Harriet Miller version")

*Making density plot white
gr_edit plotregion1.graph1.style.editstyle boxstyle(shadestyle(color(none))) editcopy
gr_edit plotregion1.graph1.style.editstyle boxstyle(linestyle(color(none))) editcopy

*Creating label for density plot
gr_edit plotregion1.graph1.yaxis1.title.draw_view.setstyle, style(yes)
gr_edit plotregion1.graph1.yaxis1.title.text = {}
gr_edit plotregion1.graph1.yaxis1.title.text.Arrpush Rudeness density

*Moving label backwards
gr_edit plotregion1.graph1.yaxis1.title.DragBy 0 -1.5

*Editing size of value labels
gr_edit plotregion1.graph1.yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(vlarge)))) editcopy
gr_edit plotregion1.graph2.yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(vlarge)))) editcopy
gr_edit plotregion1.graph2.xaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(vlarge)))) editcopy

*Slightly enlarging margin of entire plot
gr_edit style.editstyle margin(medlarge) editcopy

*Enlarging axis labels
gr_edit plotregion1.graph1.yaxis1.title.style.editstyle size(medsmall) editcopy
gr_edit plotregion1.graph2.yaxis1.title.style.editstyle size(medsmall) editcopy
gr_edit plotregion1.graph2.xaxis1.title.style.editstyle size(medsmall) editcopy

*Creating boxes around each plot
gr_edit plotregion1.graph1.plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy
gr_edit plotregion1.graph2.plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Hiding value labels below density plot
gr_edit plotregion1.graph1.xaxis1.style.editstyle majorstyle(tickstyle(position(inside))) editcopy
gr_edit plotregion1.graph1.xaxis1.style.editstyle majorstyle(tickstyle(show_labels(no))) editcopy

*Adding 0 and 1 ticks to top density plot to assure that x-axis is aligned with x-axis in plot below
gr_edit plotregion1.graph1.xaxis1.add_ticks 0 `""', tickset(major)
gr_edit plotregion1.graph1.xaxis1.add_ticks 1 `""', tickset(major)

*Saving
graph save "Temp_figures\Figure4c.gph", replace


***Combining the three subfigures, creating final figure

*Combining*
gr combine "Temp_figures\Figure4a.gph" "Temp_figures\Figure4b.gph" "Temp_figures\Figure4c.gph", col(3) imargin(0 0 0 0) ysize(5.5)

*Removing axes*
gr_edit plotregion1.graph2.plotregion1.graph1.yaxis1.title.draw_view.setstyle, style(no)
gr_edit plotregion1.graph2.plotregion1.graph1.yaxis1.draw_view.setstyle, style(no)
gr_edit plotregion1.graph2.plotregion1.graph2.yaxis1.title.draw_view.setstyle, style(no)
gr_edit plotregion1.graph2.plotregion1.graph2.yaxis1.draw_view.setstyle, style(no)
gr_edit plotregion1.graph3.plotregion1.graph1.yaxis1.title.draw_view.setstyle, style(no)
gr_edit plotregion1.graph3.plotregion1.graph2.yaxis1.title.draw_view.setstyle, style(no)
gr_edit plotregion1.graph3.plotregion1.graph1.yaxis1.draw_view.setstyle, style(no)
gr_edit plotregion1.graph3.plotregion1.graph2.yaxis1.draw_view.setstyle, style(no)

*Removing blue color from background*
gr_edit style.editstyle boxstyle(shadestyle(color(white))) editcopy
gr_edit style.editstyle boxstyle(linestyle(color(white))) editcopy

*Changing sizes of axis value labels*
gr_edit plotregion1.graph1.plotregion1.graph1.yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(medlarge)))) editcopy
gr_edit plotregion1.graph1.plotregion1.graph2.yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(medlarge)))) editcopy
gr_edit plotregion1.graph1.plotregion1.graph2.xaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(small)))) editcopy
gr_edit plotregion1.graph2.plotregion1.graph2.xaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(small)))) editcopy
gr_edit plotregion1.graph3.plotregion1.graph2.xaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(small)))) editcopy

*Changing margins around title*
gr_edit plotregion1.graph1.title.style.editstyle margin(medsmall) editcopy
gr_edit plotregion1.graph2.title.style.editstyle margin(medsmall) editcopy
gr_edit plotregion1.graph3.title.style.editstyle margin(medsmall) editcopy

*Changing size of title*
gr_edit plotregion1.graph1.title.style.editstyle size(medlarge) editcopy
gr_edit plotregion1.graph2.title.style.editstyle size(medlarge) editcopy
gr_edit plotregion1.graph3.title.style.editstyle size(medlarge) editcopy

*Moving title of first plot*
gr_edit plotregion1.graph1.title.DragBy 0 3

*Extended y axis in density plots*
gr_edit plotregion1.graph1.plotregion1.graph1.yaxis1.plotregion.yscale.curmax = 3.4
gr_edit plotregion1.graph2.plotregion1.graph1.yaxis1.plotregion.yscale.curmax = 3.4
gr_edit plotregion1.graph3.plotregion1.graph1.yaxis1.plotregion.yscale.curmax = 3.4

*Adding descriptions*
gr_edit AddTextBox added_text editor 60 8
gr_edit added_text[1].style.editstyle size(vsmall) editcopy
gr_edit added_text[1].text.Arrpush Favorability among
gr_edit added_text[1].text.Arrpush co-partisans

gr_edit AddTextBox added_text editor 32 8
gr_edit added_text[2].style.editstyle size(vsmall) editcopy
gr_edit added_text[2].text.Arrpush Favorability among
gr_edit added_text[2].text.Arrpush out-partisans

gr_edit AddTextBox added_text editor 60 38
gr_edit added_text[3].style.editstyle size(vsmall) editcopy
gr_edit added_text[3].text.Arrpush Favorability among
gr_edit added_text[3].text.Arrpush co-partisans

gr_edit AddTextBox added_text editor 32 38
gr_edit added_text[4].style.editstyle size(vsmall) editcopy
gr_edit added_text[4].text.Arrpush Favorability among
gr_edit added_text[4].text.Arrpush out-partisans

gr_edit AddTextBox added_text editor 60 68
gr_edit added_text[5].style.editstyle size(vsmall) editcopy
gr_edit added_text[5].text.Arrpush Favorability among
gr_edit added_text[5].text.Arrpush co-partisans

gr_edit AddTextBox added_text editor 32 68
gr_edit added_text[6].style.editstyle size(vsmall) editcopy
gr_edit added_text[6].text.Arrpush Favorability among
gr_edit added_text[6].text.Arrpush out-partisans

gr_edit AddTextBox added_text editor 85 8
gr_edit added_text[7].style.editstyle size(vsmall) editcopy
gr_edit added_text[7].text.Arrpush Distr. of incivility in
gr_edit added_text[7].text.Arrpush attacks by all
gr_edit added_text[7].text.Arrpush members

gr_edit AddTextBox added_text editor 85 38
gr_edit added_text[8].style.editstyle size(vsmall) editcopy
gr_edit added_text[8].text.Arrpush Distr. of incivility in
gr_edit added_text[8].text.Arrpush attacks by
gr_edit added_text[8].text.Arrpush men

gr_edit AddTextBox added_text editor 85 68
gr_edit added_text[9].style.editstyle size(vsmall) editcopy
gr_edit added_text[9].text.Arrpush Distr. of incivility in
gr_edit added_text[9].text.Arrpush attacks by
gr_edit added_text[9].text.Arrpush women

*Saving figure*
graph save "Figures\Figure4.gph", replace
}

*Calculating share of tweets with rating above 0.5 that also have rating above 0.75 (see paragraph starting with "These patterns are...")
quietly {
clear all
use "workingdatatweets.dta"
gen above075 = 0
replace above075 = 1 if Weighted_tot_average > .7523846
}
tab above075 if Mock_t != 1 & Trump_tweet != 1 & Weighted_tot_average > 0.5 & share_no_dis_or_crit < 0.25

*Calculating share of tweets with rating above 0.5 that also have rating above 0.75 among women and men (see paragraph starting with "In the two remaining...")
tab above075 if Mock_t != 1 & Trump_tweet != 1 & Weighted_tot_average > 0.5 & Gender_of == "F" & share_no_dis_or_crit < 0.25
tab above075 if Mock_t != 1 & Trump_tweet != 1 & Weighted_tot_average > 0.5 & Gender_of == "M" & share_no_dis_or_crit < 0.25

*Results from linear model reported in footnote excluding observations from two most uncivil conditions (see first footnote starting with "Excluding observations...")
quietly{
clear all
use "workingdata.dta"
gen rescaled_rude = (Rudeness_0_to_100-36)/39 if Rudeness_0_to_100 != 87 & Rudeness_0_to_100 != 92
tab rescaled_rude
}
reg Rating_M rescaled_rude if out == 0 & Only_male_version_of_exp == 1, rob

*********************************************************************
**CODE FOR SECTION CALLED "ARE THE EXPERIMENTAL RESULTS SIMILAR..."**
*********************************************************************

*Creating panel (a) of Figure 5 and saving it in folder called "Figures"
quietly {
	
***MTurk sample for Harry

*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & Only_male_version_MTturk_sample == 1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & Only_male_version_MTturk_sample == 1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) xlabel(,angle(270) format(%04.2f)) title("MTurk sample") saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans
drop if Only_male_version_MTturk_sample == 0
drop if out != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.41 0.54 0.65 0.71 0.75 0.82 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out-party_harry_mturk.gph", replace

*Adding plot of averages in each conditions for out-partisans
clear all
use "workingdata.dta"
drop if Only_male_version_MTturk_sample == 0
drop if out != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out-party_harry_mturk.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.41 0.54 0.65 0.71 0.75 0.82 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(color(black)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(color(black)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Saving figure
graph save "Temp_figures\Figure5a_Harry_Mturk.gph", replace

***MTurk sample for SSI

*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & Only_male_version_SSI_sample == 1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & Only_male_version_SSI_sample == 1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) yscale(off) xlabel(,angle(270) format(%04.2f)) fxsize(45) title("SSI sample") saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans
drop if Only_male_version_SSI_sample == 0
drop if out != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) yscale(off) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out-party_harry_ssi.gph", replace

*Adding plot of averages in each conditions for out-partisans
clear all
use "workingdata.dta"
drop if Only_male_version_SSI_sample == 0
drop if out != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out-party_harry_ssi.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) yscale(off) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(color(black)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(color(black)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Saving figure
graph save "Temp_figures\Figure5a_Harry_SSI.gph", replace

***Combing figures
gr combine "Temp_figures\Figure5a_Harry_Mturk.gph" "Temp_figures\Figure5a_Harry_SSI.gph", col(2) ysize(5)

*Removing margins
gr_edit style.editstyle margin(zero) editcopy

*Enlarging titles
gr_edit plotregion1.graph1.title.style.editstyle size(vlarge) editcopy
gr_edit plotregion1.graph2.title.style.editstyle size(vlarge) editcopy

*Making margins around titles bigger
gr_edit plotregion1.graph2.title.style.editstyle margin(medium) editcopy
gr_edit plotregion1.graph1.title.style.editstyle margin(medium) editcopy

*Adding descriptions
gr_edit AddTextBox added_text editor 84 14
gr_edit added_text[1].style.editstyle size(small) editcopy
gr_edit added_text[1].text.Arrpush Favorability among co-partisans
gr_edit AddTextBox added_text editor 42 14
gr_edit added_text[2].style.editstyle size(small) editcopy
gr_edit added_text[2].text.Arrpush Favorability among out-partisans

*Making two ticks small so they don't overlap
gr_edit plotregion1.graph1.xaxis1.edit_tick 6 0.71 `"0.71"', custom tickset(major) editstyle(tickstyle(textstyle(size(small))) )
gr_edit plotregion1.graph1.xaxis1.edit_tick 7 0.75 `"0.75"', custom tickset(major) editstyle(tickstyle(textstyle(size(small))) )

*Saving graph
graph save "Figures\Figure5a.gph", replace
}

*Testing whether average favorability is significantly higher than in adjecent conditions that is more civil among out-partisans. The relevant finding is that only when comparing conditions 0.71 and 0.65 among out-partisans (line 983) is the coefficient both positive and significant (i.e., p<0.05). (see paragraph starting with "Furthermore, the more...").
quietly {
clear all
use "workingdata.dta"
gen _036_vs_041 = 0 if Rudeness == 36
replace _036_vs_041 = 1 if Rudeness == 41
gen _054_vs_041  = 0 if Rudeness == 41
replace _054_vs_041 = 1 if Rudeness == 54
gen _065_vs_054 = 0 if Rudeness == 54
replace _065_vs_054 = 1 if Rudeness == 65
gen _071_vs_065 = 0 if Rudeness == 65
replace _071_vs_065 = 1 if Rudeness == 71
gen _075_vs_071 = 0 if Rudeness == 71
replace _075_vs_071 = 1 if Rudeness == 75
gen _082_vs_075 = 0 if Rudeness == 75
replace _082_vs_075 = 1 if Rudeness == 82
gen _087_vs_082 = 0 if Rudeness == 82
replace _087_vs_082 = 1 if Rudeness == 87
gen _092_vs_087 = 0 if Rudeness == 87
replace _092_vs_087 = 1 if Rudeness == 92
}

reg Rating_M _036_vs_041 if out == 1 & Sample == 0, rob
reg Rating_M _054_vs_041 if out == 1 & Sample == 0, rob
reg Rating_M _065_vs_054 if out == 1 & Sample == 0, rob
reg Rating_M _071_vs_065 if out == 1 & Sample == 0, rob
reg Rating_M _075_vs_071 if out == 1 & Sample == 0, rob
reg Rating_M _082_vs_075 if out == 1 & Sample == 0, rob
reg Rating_M _087_vs_082 if out == 1 & Sample == 0, rob
reg Rating_M _092_vs_087 if out == 1 & Sample == 0, rob

reg Rating_M _036_vs_041 if out == 0 & Sample == 0, rob
reg Rating_M _054_vs_041 if out == 0 & Sample == 0, rob
reg Rating_M _065_vs_054 if out == 0 & Sample == 0, rob
reg Rating_M _071_vs_065 if out == 0 & Sample == 0, rob
reg Rating_M _075_vs_071 if out == 0 & Sample == 0, rob
reg Rating_M _082_vs_075 if out == 0 & Sample == 0, rob
reg Rating_M _087_vs_082 if out == 0 & Sample == 0, rob
reg Rating_M _092_vs_087 if out == 0 & Sample == 0, rob

*******************************************************
**CODE FOR SECTION CALLED "DO STRONG PARTISANS OR..."**
*******************************************************

*Creating panel (b) of Figure 5 and saving it in folder called "Figures"
quietly {
	
***Strong partisans

*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & Pooled_analysis == 1 & (StrongRep == 1 | StrongDem == 1), bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & Pooled_analysis == 1 & (StrongRep == 1 | StrongDem == 1), bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) xlabel(,angle(270) format(%04.2f)) title("Strong partisans") saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans
drop if  Pooled_analysis == 0 | (StrongRep != 1 & StrongDem != 1)
drop if out != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out-party_strong.gph", replace

*Adding plot of averages in each conditions for co-partisans
clear all
use "workingdata.dta"
drop if  Pooled_analysis == 0 | (StrongRep != 1 & StrongDem != 1)
drop if out != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out-party_strong.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(color(black)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(color(black)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Saving figure
graph save "Temp_figures\Figure5b_Strong.gph", replace

***Low SM

*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & Only_male_version_of_exp == 1 & (SM < 0.34 & SM > -2), bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & Only_male_version_of_exp == 1 & (SM < 0.34 & SM > -2), bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) yscale(off) xlabel(,angle(270) format(%04.2f)) fxsize(45) title("Low self-monitoring") saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans
drop if Only_male_version_of_exp == 0 | (SM == . | SM > 0.34)
drop if out != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) yscale(off) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out-party_low_SM.gph", replace

*Adding plot of averages in each conditions for co-partisans
clear all
use "workingdata.dta"
drop if Only_male_version_of_exp == 0 | (SM == . | SM > 0.34)
drop if out != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out-party_low_SM.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) yscale(off) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(color(black)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(color(black)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Saving figure
graph save "Temp_figures\Figure5b_low_SM.gph", replace

***Combing subfigures
gr combine "Temp_figures\Figure5b_Strong.gph" "Temp_figures\Figure5b_low_SM.gph", col(2) ysize(5)

*Removing margins
gr_edit style.editstyle margin(zero) editcopy

*Enlarging titles
gr_edit plotregion1.graph1.title.style.editstyle size(vlarge) editcopy
gr_edit plotregion1.graph2.title.style.editstyle size(vlarge) editcopy

*Making margins around titles bigger
gr_edit plotregion1.graph2.title.style.editstyle margin(medium) editcopy
gr_edit plotregion1.graph1.title.style.editstyle margin(medium) editcopy

*Adding descriptions
gr_edit AddTextBox added_text editor 84 14
gr_edit added_text[1].style.editstyle size(small) editcopy
gr_edit added_text[1].text.Arrpush Favorability among co-partisans
gr_edit AddTextBox added_text editor 42 14
gr_edit added_text[2].style.editstyle size(small) editcopy
gr_edit added_text[2].text.Arrpush Favorability among out-partisans

*Saving graph
graph save "Figures\Figure5b.gph", replace
}

*****************************************************************
**CODE FOR SECTION CALLED "DO DEMOCRATS REACT MORE STRONGLY..."**
*****************************************************************

*Creating panel (c) of Figure 5 and saving it in folder called "Figures"
quietly {

***Democrats

*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & Pooled_analysis == 1 & Dem0==0, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & Pooled_analysis == 1 & Dem0==0, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) xlabel(,angle(270) format(%04.2f)) title("Democrats") saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans
drop if  Pooled_analysis == 0 | Dem0!=0
drop if out != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out-party_Dem.gph", replace

*Adding plot of averages in each conditions for co-partisans
clear all
use "workingdata.dta"
drop if  Pooled_analysis == 0 | Dem0!=0
drop if out != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out-party_Dem.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(color(black)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(color(black)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Saving figure
graph save "Temp_figures\Figure5c_Dem.gph", replace

***Republicans

*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & Pooled_analysis == 1 & Dem0==1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & Pooled_analysis == 1 & Dem0==1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) yscale(off) xlabel(,angle(270) format(%04.2f)) fxsize(45) title("Republicans") saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans*
drop if  Pooled_analysis == 0 | Dem0!=1
drop if out != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) yscale(off) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out-party_Rep.gph", replace

*Adding plot of averages in each conditions for co-partisans
clear all
use "workingdata.dta"
drop if Pooled_analysis == 0 | Dem0!=1
drop if out != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out-party_Rep.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) yscale(off) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(color(black)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(color(black)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Saving figure
graph save "Temp_figures\Figure5c_Rep.gph", replace

***Combining subfigures
gr combine "Temp_figures\Figure5c_Dem.gph" "Temp_figures\Figure5c_Rep.gph", col(2) ysize(5)

*Removing margins
gr_edit style.editstyle margin(zero) editcopy

*Enlarging titles
gr_edit plotregion1.graph1.title.style.editstyle size(vlarge) editcopy
gr_edit plotregion1.graph2.title.style.editstyle size(vlarge) editcopy

*Making margins around titles bigger
gr_edit plotregion1.graph2.title.style.editstyle margin(medium) editcopy
gr_edit plotregion1.graph1.title.style.editstyle margin(medium) editcopy

*Adding descriptions
gr_edit AddTextBox added_text editor 84 14
gr_edit added_text[1].style.editstyle size(small) editcopy
gr_edit added_text[1].text.Arrpush Favorability among co-partisans
gr_edit AddTextBox added_text editor 42 14
gr_edit added_text[2].style.editstyle size(small) editcopy
gr_edit added_text[2].text.Arrpush Favorability among out-partisans

*Saving graph
graph save "Figures\Figure5c.gph", replace
}

*Linear model reported in footnote excluding observations from two most uncivil conditions (see second footnote starting with "Excluding observations...")
quietly{
clear all
use "workingdata.dta"
gen rescaled_rude = (Rudeness_0_to_100-36)/39 if (Rudeness_0_to_100 != 87 & Rudeness_0_to_100 != 92)
tab rescaled_rude
}
reg Rating_M rescaled_rude if out == 0 & Pooled_analysis == 1 & Dem0 == 0, rob

*Showing that share of strong partisans is slightly larger among Democrats than among Republicans (see paragraph starting with "A more notable difference...")
quietly{
clear all
use "workingdata.dta"
gen StrongDem_dummy = 0 if (seven == 5 | seven == 6 | seven == 7)
replace StrongDem_dummy = 1 if seven == 7
gen StrongRep_dummy = 0 if (seven == 1 | seven == 2 | seven == 3)
replace StrongRep_dummy = 1 if seven == 1
}
tab StrongDem_dummy
tab StrongRep_dummy

*****************************************************************************************
**CODE FOR SECTION CALLED "IS EXTREME INCIVILITY AMPLIFIED BY NEWS MEDIA AND SOCIAL..."**
*****************************************************************************************

*Creating Figure 6 and saving it in folder called "Figures"
quietly {
clear all
use "workingdatatweets.dta"

kdensity Weighted_tot_average if Trump == 0 & Mock_t == 0 & share_no_dis_or_crit < 0.25 & Number_shares != 159922 [fw=Number_shares], bwidth(0.04) scheme(s1mono) xlabels(0.36 0.54 0.65 0.75 0.87 0.92) lcolor(black) ysize(3)
addplot Graph: kdensity Weighted_tot_average if Trump == 0 & Mock_t == 0 & share_no_dis_or_crit < 0.25, bwidth(0.04) xlabels(0.36 0.54 0.65 0.75 0.87 0.92) lcolor(black)

gr_edit title.draw_view.setstyle, style(no)
gr_edit plotregion1.plot1.style.editstyle line(color(gs7)) editcopy
gr_edit xaxis1.title.draw_view.setstyle, style(no)
gr_edit legend.plotregion1.label[2].text = {}
gr_edit legend.plotregion1.label[2].text.Arrpush Incivility in what is tweeted (original distr.)
gr_edit legend.plotregion1.label[1].text = {}
gr_edit legend.plotregion1.label[1].text.Arrpush Incivility in what is retweeted
gr_edit note.draw_view.setstyle, style(no)
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit legend.plotregion1.label[1].style.editstyle size(large) editcopy
gr_edit legend.plotregion1.label[2].style.editstyle size(large) editcopy
gr_edit plotregion1.plot1.style.editstyle line(width(medthick)) editcopy
gr_edit plotregion1.plot2.style.editstyle line(width(medthick)) editcopy
graph save "Figures\Figure6.gph", replace
}

*Rudeness rating for Feinstein tweet excluded from analysis (see footnote starting with "One tweet by Senator...")
sum Weighted_tot_average if Number_shares == 159922

*Calculating share of tweets with rating above 0.5 that also have rating above 0.75 when retweet count is used as frequency weights (see paragraph starting with "While my study cannot")
quietly {
clear all
use "workingdatatweets.dta"
gen above075 = 0
replace above075 = 1 if Weighted_tot_average > .7523846
}
tab above075 [fweight=Number_shares] if Mock_t == 1 != 1 & Trump_tweet != 1 & Weighted_tot_average > 0.5 & share_no_dis_or_crit < 0.25 & Number_shares != 159922

***************
**CODE FOR A2**
***************

*Creating Figure 1 and saving it in folder called "Figures"
quietly {

clear all
use "workingdatatweets.dta"

*First panel
kdensity Weighted_tot_average if Trump == 0 & Mock_t == 0 & share_no_dis_or_crit < 0.25, bwidth(0.04) scheme(s1mono) xlabels(0 0.36 0.54 0.65 0.75 0.87 0.92 1) lcolor(black)
gr_edit title.draw_view.setstyle, style(no)
gr_edit xaxis1.title.draw_view.setstyle, style(no)
gr_edit note.draw_view.setstyle, style(no)
gr_edit yaxis1.title.draw_view.setstyle, style(no)
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
graph save "Temp_figures\Figure1_A2_a.gph", replace

*Second panel
kdensity Simple if Trump == 0 & Mock_t == 0 & share_no_dis_or_crit < 0.25, bwidth(0.04) scheme(s1mono) xlabels(0 0.33 0.53 0.65 0.77 0.88 0.92 1) lcolor(black)
gr_edit title.draw_view.setstyle, style(no)
gr_edit xaxis1.title.draw_view.setstyle, style(no)
gr_edit note.draw_view.setstyle, style(no)
gr_edit yaxis1.title.draw_view.setstyle, style(no)
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
graph save "Temp_figures\Figure1_A2_b.gph", replace

*Third panel
kdensity Average_rating_partial_pooling if Trump == 0 & Mock_t == 0 & share_no_dis_or_crit < 0.25, bwidth(0.04) scheme(s1mono) xlabels(0 0.34 0.53 0.65 0.76 0.87 0.91 1) lcolor(black)
gr_edit title.draw_view.setstyle, style(no)
gr_edit xaxis1.title.draw_view.setstyle, style(no)
gr_edit note.draw_view.setstyle, style(no)
gr_edit yaxis1.title.draw_view.setstyle, style(no)
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(none))) editcopy
graph save "Temp_figures\Figure1_A2_c.gph", replace

graph combine "Temp_figures\Figure1_A2_a.gph" "Temp_figures\Figure1_A2_b.gph" "Temp_figures\Figure1_A2_c.gph", col(1) scheme(s1mono) ysize(5)

gr_edit plotregion1.graph1.subtitle.text = {}
gr_edit plotregion1.graph1.subtitle.text.Arrpush Incivility scores calculated as weighted average of ratings
gr_edit plotregion1.graph2.subtitle.text = {}
gr_edit plotregion1.graph2.subtitle.text.Arrpush Incivility scores calculated as simple average of ratings
gr_edit plotregion1.graph3.subtitle.text = {}
gr_edit plotregion1.graph3.subtitle.text.Arrpush Partial pooling, incivility scores predicted from random intercepts model
graph save "Figures\Appendix_Figure1.gph", replace
}

***************
**CODE FOR A5**
***************

*Coder demographics in first round of content analysis (see "First round" column in Table 1)

***Coder emographics (see A5, table 1, fist column)***
quietly {
clear all
use "data_Content_analysis_data_from_first_round.dta"
duplicates drop Respondentid, force
gen Dem_dummy = 0
replace Dem_dummy = 1 if (Coder_party_ID == 1 | Coder_party_ID == 2 | Coder_party_ID == 3)
gen Rep_dummy = 0
replace Rep_dummy = 1 if (Coder_party_ID == 5 | Coder_party_ID == 6 | Coder_party_ID == 7)
}
mean Coder_age
tab Coder_gender
tab Coder_education
tab Rep_dummy
tab Dem_dummy

*Coder demographics in second round of content analysis (see "Second round" column in Table 1)
quietly {
clear all
use "data_Content_analysis_data_from_second_round.dta"
duplicates drop RespondentID, force
gen Dem_dummy = 0
replace Dem_dummy = 1 if (PartyID_ag == 1 | PartyID_ag == 2 | PartyID_ag == 3)
gen Rep_dummy = 0
replace Rep_dummy = 1 if (PartyID_ag == 5 | PartyID_ag == 6 | PartyID_ag == 7)
}
mean Coder_age
tab Coder_gender
tab Coder_education
tab Rep_dummy
tab Dem_dummy

*Coder demographics for experimental survey participants (see Table 2)
quietly {
clear all
use "workingdata.dta"
gen Dem_dummy = 0
replace Dem_dummy = 1 if Dem0 == 0
gen Rep_dummy = 0
replace Rep_dummy = 1 if Dem0 == 1
}
mean Age, over(Sample)
tab Sample Gender, row
tab Education if Sample == 0
tab Education if Sample == 1
tab Education if Sample == 2
tab Sample Rep_dummy, row
tab Sample Dem_dummy, row

***************
**CODE FOR A6**
***************

***Means across all samples (see Table 3)
quietly {
clear all
use "workingdata.dta"
}
mean Rating_M if out == 0 & Pooled_analysis == 1, over(Rudeness_0_to_100) 
mean Rating_M if out == 1 & Pooled_analysis == 1, over(Rudeness_0_to_100) 

*Signficance testing to create stars (see Table 3)
reg Rating_M i.Rudeness_0_to_100 if out == 0 & Pooled_analysis == 1, rob
reg Rating_M i.Rudeness_0_to_100 if out == 1 & Pooled_analysis == 1, rob

***Only Harry Miller version (see Table 4)
mean Rating_M if out == 0 & Only_male_version_of_exp == 1, over(Rudeness_0_to_100) 
mean Rating_M if out == 1 & Only_male_version_of_exp == 1, over(Rudeness_0_to_100) 

*Signficance testing to create stars (see Table 4)
reg Rating_M i.Rudeness_0_to_100 if out == 0 & Only_male_version_of_exp == 1, rob
reg Rating_M i.Rudeness_0_to_100 if out == 1 & Only_male_version_of_exp == 1, rob

***Only Hariet Miller Version (see Table 5)
mean Rating_M if Only_female_version_of_exp == 1 & out == 0, over(Rudeness_0_to_100) 
mean Rating_M if Only_female_version_of_exp == 1 & out == 1, over(Rudeness_0_to_100) 

*Signficance testing to create stars (see Table 5)
reg Rating_M i.Rudeness_0_to_100 if Only_female_version_of_exp == 1 & out == 0, rob
reg Rating_M i.Rudeness_0_to_100 if Only_female_version_of_exp == 1 & out == 1, rob

***Only Harry-MTurk Version (see table 6)
mean Rating_M if Only_male_version_MTturk_sample == 1 & out == 0, over(Rudeness_0_to_100) 
mean Rating_M if Only_male_version_MTturk_sample == 1 & out == 1, over(Rudeness_0_to_100) 

*Signficance testing to create stars (see Table 6)
reg Rating_M i.Rudeness_0_to_100 if Only_male_version_MTturk_sample == 1 & out == 0, rob
reg Rating_M i.Rudeness_0_to_100 if Only_male_version_MTturk_sample == 1 & out == 1, rob

***Only Harry-SSI Version (see table 7)
mean Rating_M if Only_male_version_SSI_sample == 1 & out == 0, over(Rudeness_0_to_100) 
mean Rating_M if Only_male_version_SSI_sample == 1 & out == 1, over(Rudeness_0_to_100) 

*Signficance testing to create stars (see Table 6)
reg Rating_M i.Rudeness_0_to_100 if Only_male_version_SSI_sample == 1 & out == 0, rob
reg Rating_M i.Rudeness_0_to_100 if Only_male_version_SSI_sample == 1 & out == 1, rob

***************
**CODE FOR A7**
***************

*Testing whether partisans respond differently to in- and out-party incivility (Table 8)
quietly {
clear all
use "workingdata.dta"
}
reg Rating_M Rudeness_0_to_100##out if Pooled_analysis == 1, rob

***************
**CODE FOR A8**
***************

*Creating Figure 2 and saving it in folder called "Figures"
quietly {
*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & Atcheck_passed == 1 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & Atcheck_passed == 1 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) xlabel(,angle(270) format(%04.2f)) saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans
drop if Pooled_analysis == 0 | Atcheck_passed == 0
drop if out != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out_Atcheckpassed.gph", replace

*Adding plot of averages in each conditions for co-partisans
clear all
use "workingdata.dta"
drop if Pooled_analysis == 0 | Atcheck_passed == 0
drop if out != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out_Atcheckpassed.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style editstyle line(pattern(dash)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(pattern(dash)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Adding descriptions
gr_edit AddTextBox added_text editor 125 14
gr_edit added_text[1].style.editstyle size(medium) editcopy
gr_edit added_text[1].text.Arrpush Favorability among co-partisans
gr_edit AddTextBox added_text editor 55 14
gr_edit added_text[2].style.editstyle size(medium) editcopy
gr_edit added_text[2].text.Arrpush Favorability among out-partisans

*Saving figure
graph save "Figures\Appendix_Figure2", replace
}

*Creating Figure 3 and saving it in folder called "Figures" (each panel saved sep.)
quietly {
	
***Panel a

*Creating smoothed lines
clear all
use "workingdata.dta"
gen no_col_degree_0_col_degree_1 = .
replace no_col_degree_0_col_degree_1 = 0 if Education == 1 | Education == 2 | Education == 3
replace no_col_degree_0_col_degree_1 = 1 if Education == 4 | Education == 5 | Education == 6 | Education == 7 | Education == 8
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & no_col_degree_0_col_degree_1 == 0 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & no_col_degree_0_col_degree_1 == 0 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) xlabel(,angle(270) format(%04.2f)) saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans
drop if Pooled_analysis == 0
drop if out != 1 | no_col_degree_0_col_degree_1 != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out_No_col.gph", replace

*Adding plot of averages in each conditions for co-partisans
clear all
use "workingdata.dta"
gen no_col_degree_0_col_degree_1 = .
replace no_col_degree_0_col_degree_1 = 0 if Education == 1 | Education == 2 | Education == 3
replace no_col_degree_0_col_degree_1 = 1 if Education == 4 | Education == 5 | Education == 6 | Education == 7 | Education == 8
drop if Pooled_analysis == 0
drop if out != 0 | no_col_degree_0_col_degree_1 != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out_No_col.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(pattern(dash)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(pattern(dash)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Adding descriptions
gr_edit AddTextBox added_text editor 125 14
gr_edit added_text[1].style.editstyle size(medium) editcopy
gr_edit added_text[1].text.Arrpush Favorability among co-partisans
gr_edit AddTextBox added_text editor 55 14
gr_edit added_text[2].style.editstyle size(medium) editcopy
gr_edit added_text[2].text.Arrpush Favorability among out-partisans

*Saving figure
graph save "Figures\Appendix_Figure3A", replace

***Panel b

*Creating smoothed lines
clear all
use "workingdata.dta"
gen no_col_degree_0_col_degree_1 = .
replace no_col_degree_0_col_degree_1 = 0 if Education == 1 | Education == 2 | Education == 3
replace no_col_degree_0_col_degree_1 = 1 if Education == 4 | Education == 5 | Education == 6 | Education == 7 | Education == 8
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & no_col_degree_0_col_degree_1 == 1 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & no_col_degree_0_col_degree_1 == 1 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) xlabel(,angle(270) format(%04.2f)) saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans
drop if Pooled_analysis == 0
drop if out != 1 | no_col_degree_0_col_degree_1 != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out_Col.gph", replace

*Adding plot of averages in each conditions for co-partisans
clear all
use "workingdata.dta"
gen no_col_degree_0_col_degree_1 = .
replace no_col_degree_0_col_degree_1 = 0 if Education == 1 | Education == 2 | Education == 3
replace no_col_degree_0_col_degree_1 = 1 if Education == 4 | Education == 5 | Education == 6 | Education == 7 | Education == 8
drop if Pooled_analysis == 0
drop if out != 0 | no_col_degree_0_col_degree_1 != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out_Col.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(pattern(dash)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(pattern(dash)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Adding descriptions
gr_edit AddTextBox added_text editor 125 14
gr_edit added_text[1].style.editstyle size(medium) editcopy
gr_edit added_text[1].text.Arrpush Favorability among co-partisans
gr_edit AddTextBox added_text editor 65 14
gr_edit added_text[2].style.editstyle size(medium) editcopy
gr_edit added_text[2].text.Arrpush Favorability among out-partisans

*Saving figure
graph save "Figures\Appendix_Figure3B", replace
}

*Creating Figure 4 and saving it in folder called "Figures" (each panel saved sep.)
quietly{
	
***Panel a

*Creating smoothed lines
clear all
use "workingdata.dta"
gen over40_years = .
replace over40_years = 0 if Age < 39.5 & Age > 0
replace over40_years = 1 if Age > 39.5 & Age < 101
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & over40_years == 0 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & over40_years == 0 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) xlabel(,angle(270) format(%04.2f)) saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans
drop if Pooled_analysis == 0
drop if out != 1 | over40_years != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out_under40.gph", replace

*Adding plot of averages in each conditions for co-partisans
clear all
use "workingdata.dta"
gen over40_years = .
replace over40_years = 0 if Age < 39.5 & Age > 0
replace over40_years = 1 if Age > 39.5 & Age < 101
drop if Pooled_analysis == 0
drop if out != 0 | over40_years != 0
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out_under40.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(pattern(dash)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(pattern(dash)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Adding descriptions
gr_edit AddTextBox added_text editor 125 14
gr_edit added_text[1].style.editstyle size(medium) editcopy
gr_edit added_text[1].text.Arrpush Favorability among co-partisans
gr_edit AddTextBox added_text editor 65 14
gr_edit added_text[2].style.editstyle size(medium) editcopy
gr_edit added_text[2].text.Arrpush Favorability among out-partisans

*Saving figure
graph save "Figures\Appendix_Figure4A", replace

***Panel b

*Creating smoothed lines
clear all
use "workingdata.dta"
gen over40_years = .
replace over40_years = 0 if Age < 39.5 & Age > 0
replace over40_years = 1 if Age > 39.5 & Age < 101
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & over40_years == 1 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & over40_years == 1 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) xlabel(,angle(270) format(%04.2f)) saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans
drop if Pooled_analysis == 0
drop if out != 1 | over40_years != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out_Over40.gph", replace

*Adding plot of averages in each conditions for out-partisans
clear all
use "workingdata.dta"
gen over40_years = .
replace over40_years = 0 if Age < 39.5 & Age > 0
replace over40_years = 1 if Age > 39.5 & Age < 101
drop if Pooled_analysis == 0
drop if out != 0 | over40_years != 1
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out_Over40.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(pattern(dash)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(pattern(dash)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Adding descriptions
gr_edit AddTextBox added_text editor 125 14
gr_edit added_text[1].style.editstyle size(medium) editcopy
gr_edit added_text[1].text.Arrpush Favorability among co-partisans
gr_edit AddTextBox added_text editor 55 14
gr_edit added_text[2].style.editstyle size(medium) editcopy
gr_edit added_text[2].text.Arrpush Favorability among out-partisans

*Saving figure
graph save "Figures\Appendix_Figure4B", replace
}

*Creating Figure 5 and saving it in folder called "Figures" (each panel saved sep.)
quietly {
	
***Panel a
	
*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & Gender == 4 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & Gender == 4 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) xlabel(,angle(270) format(%04.2f)) saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans
drop if Pooled_analysis == 0
drop if out != 1 | Gender != 4
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out_Men.gph", replace

*Adding plot of averages in each conditions for co-partisans
clear all
use "workingdata.dta"
drop if Pooled_analysis == 0
drop if out != 0 | Gender != 4
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out_Men.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(pattern(dash)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(pattern(dash)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Adding descriptions
gr_edit AddTextBox added_text editor 125 14
gr_edit added_text[1].style.editstyle size(medium) editcopy
gr_edit added_text[1].text.Arrpush Favorability among co-partisans
gr_edit AddTextBox added_text editor 65 14
gr_edit added_text[2].style.editstyle size(medium) editcopy
gr_edit added_text[2].text.Arrpush Favorability among out-partisans

*Saving figure
graph save "Figures\Appendix_Figure5A", replace

***Panel b

*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly Rating_Miller Tweet_rudeness_rating if out == 1 & Gender == 5 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly Rating_Miller Tweet_rudeness_rating if out == 0 & Gender == 5 & Pooled_analysis == 1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) xlabel(,angle(270) format(%04.2f)) saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans
drop if Pooled_analysis == 0
drop if out != 1 | Gender != 5
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out_Women.gph", replace

*Adding plot of averages in each conditions for co-partisans
clear all
use "workingdata.dta"
drop if Pooled_analysis == 0
drop if out != 0 | Gender != 5
collapse (mean) y = Rating_Miller (semean) se_y = Rating_Miller, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out_Women.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(black) connect(1) lpattern(solid)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines dashed
gr_edit plotregion1.plot2.style.editstyle line(pattern(dash)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(pattern(dash)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Adding descriptions
gr_edit AddTextBox added_text editor 125 14
gr_edit added_text[1].style.editstyle size(medium) editcopy
gr_edit added_text[1].text.Arrpush Favorability among co-partisans
gr_edit AddTextBox added_text editor 65 14
gr_edit added_text[2].style.editstyle size(medium) editcopy
gr_edit added_text[2].text.Arrpush Favorability among out-partisans

*Saving figure
graph save "Figures\Appendix_Figure5B", replace
}

*Creating Figure 6 and saving it in folder called "Figures"
quietly {
	
*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly AltFavorability Tweet_rudeness_rating if out == 1 & Only_male_version_SSI_sample == 1, bwidth(0.07) n(1000) lcolor(gs10)) (lpoly AltFavorability Tweet_rudeness_rating if out == 0 & Only_male_version_SSI_sample == 1, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) xlabel(,angle(270) format(%04.2f)) saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions for out-partisans
drop if  Only_male_version_SSI_sample == 0
drop if out != 1
collapse (mean) y = AltFavorability (semean) se_y = AltFavorability, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Out_Altfav.gph", replace

*Adding plot of averages in each conditions for co-partisans
clear all
use "workingdata.dta"
drop if Only_male_version_SSI_sample == 0
drop if out != 0
collapse (mean) y = AltFavorability (semean) se_y = AltFavorability, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\Out_Altfav.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines black
gr_edit plotregion1.plot2.style.editstyle line(color(black)) editcopy
gr_edit plotregion1.plot1.style.editstyle line(color(black)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Adding descriptions
gr_edit AddTextBox added_text editor 125 14
gr_edit added_text[1].style.editstyle size(medium) editcopy
gr_edit added_text[1].text.Arrpush Favorability among co-partisans
gr_edit AddTextBox added_text editor 70 14
gr_edit added_text[2].style.editstyle size(medium) editcopy
gr_edit added_text[2].text.Arrpush Favorability among out-partisans

*Saving figure
graph save "Figures\Appendix_Figure6", replace
}

***************
**CODE FOR A9**
***************

*Creating Figure 7 and saving it in folder called "Figures"
quietly {
	
*Creating smoothed lines
clear all
use "workingdata.dta"
twoway (lpoly AltFavorability Tweet_rudeness_rating if Pooled_analysis == 1 & sevenpoint_partyid == 4, bwidth(0.07) n(1000) lcolor(gs10)), legend(off) ysize(8) norescaling yscale(range(20 85)) xlabel(,angle(270) format(%04.2f)) saving("Temp_figures\temp.gph", replace) fysize(150)

*Making plot of averages in each conditions
drop if Pooled_analysis == 0
drop if sevenpoint_partyid != 4
collapse (mean) y = AltFavorability (semean) se_y = AltFavorability, by(Tweet_rudeness_rating)
gen yu = y + 1.96*se_y
gen yl = y - 1.96*se_y
graph use "Temp_figures\temp.gph"
addplot: scatter y Tweet_rudeness_rating, msymbol(circle) mcolor(black) mfcolor(black) lcolor(gs10) connect(1) lpattern(dash)
addplot: rspike yu yl Tweet_rudeness_rating, yscale(range(20 85)) ylabel(20 30 40 50 60 70 80) graphregion(color(white)) lcolor(black) xlabel(0 0.36 0.54 0.65 0.75 0.87 0.92 1) xscale(range(0 1))
graph save "Temp_figures\Independents.gph", replace

*Creating new axis labels
gr_edit yaxis1.title.text = {}
gr_edit yaxis1.title.text.Arrpush Thermometer rating
gr_edit xaxis1.title.text = {}
gr_edit xaxis1.title.text.Arrpush Rudeness rating

*Dragging labels
gr_edit yaxis1.title.DragBy 0 -2.3
gr_edit xaxis1.title.DragBy -2.3 0

*Making smoothed lines black
gr_edit plotregion1.plot1.style.editstyle line(color(black)) editcopy

*Creating box around plot
gr_edit plotregion1.style.editstyle boxstyle(linestyle(color(black))) editcopy

*Making labels bigger
gr_edit yaxis1.title.style.editstyle size(large) editcopy
gr_edit yaxis1.style.editstyle majorstyle(tickstyle(textstyle(size(large)))) editcopy
gr_edit xaxis1.title.style.editstyle size(large) editcopy

*Adding descriptions
gr_edit AddTextBox added_text editor 105 14
gr_edit added_text[1].style.editstyle size(medium) editcopy
gr_edit added_text[1].text.Arrpush Favorability among pure independents

*Saving figure
graph save "Figures\Appendix_Figure7", replace
}

****************
**CODE FOR A10**
****************

*Calculating average ratings of "the politicians whom Miuller was criticizing" (see Table 9)
quietly {
clear all
use "workingdata.dta"
}
mean Rating_those if out == 0 & Pooled_analysis == 1, over(Rudeness_0_to_100) 
mean Rating_those if out == 1 & Pooled_analysis == 1, over(Rudeness_0_to_100) 

*significance testing to create stars in table (see Table 9)
reg Rating_those i.Rudeness_0_to_100 if out == 0 & Pooled_analysis == 1, rob
reg Rating_those i.Rudeness_0_to_100 if out == 1 & Pooled_analysis == 1, rob

****************
**CODE FOR A11**
****************

*Calculating average perceived rudeness (see Table 10)
quietly {
clear all
use "workingdata.dta"
}
mean perceived_rudeness if out == 0 & Pooled_analysis == 1, over(Rudeness_0_to_100) 
mean perceived_rudeness if out == 1 & Pooled_analysis == 1, over(Rudeness_0_to_100) 

*Calculating average perceived ideology (see Table 10)
quietly {
gen Miller_attacking_Reps_dummy = 0
replace Miller_attacking_Reps_dummy = 1 if Treat > 10
}
mean perceived_ideology if Miller_attacking_Reps_dummy == 0 & Pooled_analysis == 1, over(Rudeness_0_to_100) 
mean perceived_ideology if Miller_attacking_Reps_dummy == 1 & Pooled_analysis == 1, over(Rudeness_0_to_100)